-- @owner: opentestcase023
-- @date: 2022/02/24
-- @testpoint: 创建instead of insert on触发器指定each statement条件，合理报错


--step1:建表;expect:成功
drop table if exists t_trigger_src_58 cascade;
create table t_trigger_src_58(id1 int, id2 int, id3 int) with (storage_type=ustore);

--step2:创建instead of insert on触发器指定each statement条件;expect:合理报错
create or replace view t_trigger_src_58_view1 as select * from t_trigger_src_58;
create or replace function insert_func()
returns trigger as $$
begin
insert into t_trigger_src_58 values(new.id1,new.id2,new.id3);
return new;
end;
$$language plpgsql;
/
drop trigger if exists insert_trigger_1 on t_trigger_src_58_view1;
create trigger insert_trigger_1
instead of insert on t_trigger_src_58_view1
for each statement
execute procedure insert_func();
/

--step3:清理环境;expect:成功
drop trigger if exists insert_trigger_1 on t_trigger_src_58_view1;
drop table if exists t_trigger_src_58 cascade;
drop view if exists t_trigger_src_58_view1;
drop function if exists insert_func;